package role

import (
	"parking-lot-go-admin/controller"
	"parking-lot-go-admin/model/admin"

	"github.com/gin-gonic/gin"
)

func UpdateUserRole(c *gin.Context) {

	requestDataStruct := struct {
		AdminId int   `json:"id"`
		Roles   []int `json:"roles"`
	}{}

	c.ShouldBindJSON(&requestDataStruct)

	//查询信息
	var adminWithGroupStruct admin.AdminWithGroupStruct
	if err := adminWithGroupStruct.UpdateRole(requestDataStruct.AdminId, requestDataStruct.Roles); err != nil {
		controller.Fail(c, err.Error())
		return
	}
	controller.Success(c, "")
}
